import api from "./api";
import { AgentGroup, Agent } from "../types/index";

/**
 * 获取智能体列表的all group
 * @returns 智能体列表的all group
 */
export const getAllAgentGroup = async (): Promise<AgentGroup[]> => {
  const response = await api.get<AgentGroup[]>("/ai/getAllAIGroup");
  return response.data as AgentGroup[];
};

/**
 * 根据分组获取智能体列表
 * @param groupID 分组id
 * @returns 智能体列表
 */
export const getAgentsByGroup = async (groupID: number): Promise<Agent[]> => {
  const response = await api.get<Agent[]>("/ai/getAgentByGroup", {
    params: { groupID },
  });
  return response.data as Agent[];
};

/**
 * 搜索智能体
 * @param keyword 搜索关键词
 * @returns 匹配的智能体列表
 */
export const searchAgents = async (keyword: string): Promise<Agent[]> => {
  const response = await api.post<Agent[]>("/ai/searchAgents", { keyword });
  return response.data as Agent[];
};
